﻿using System;

namespace CzfSDK
{
	public static class MathTool
	{
		public static int Clamp(this int val, int min, int max)
		{
			if (max > min) {
				val = Math.Max (min, val);
				val = Math.Min (max, val);
			} else {
				val = Math.Min (min, val);
				val = Math.Max (max, val);
			}
			return val;
		}

		public static double GetLength(double x1, double y1, double x2, double y2)
		{
			double x = x2 - x1;
			double y = y2 - y1;
			return Math.Sqrt (x * x + y * y);
		}

		public static bool Between(this int val, int min, int max)
		{
			return val <= max && val >= min;
		}
	}
}

